<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008, Thoraxcentrum, Erasmus MC, Rotterdam, The Netherlands

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Generated by Altova MapForce 2008. Code changed and improved by Maarten JB van Ettinger.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:n="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3:meta:voc" xmlns:tbf="http://www.altova.com/MapForce/UDF/tbf" xmlns:user="http://www.altova.com/MapForce/UDF/user" xmlns:vmf="http://www.altova.com/MapForce/UDF/vmf" exclude-result-prefixes="tbf user vmf xs xsi xsl" xmlns="urn:hl7-org:v3">
	<xsl:template name="tbf:ED_no_tn">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@encoding">
			<xsl:attribute name="encoding">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@mediaType">
			<xsl:attribute name="mediaType">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@compression">
			<xsl:attribute name="compression">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@integrityCheck">
			<xsl:attribute name="integrityCheck">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@integrityCheckAlgorithm">
			<xsl:attribute name="integrityCheckAlgorithm">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:reference">
			<n:reference>
				<xsl:call-template name="tbf:TEL">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:reference>
		</xsl:for-each>
		<xsl:for-each select="n:thumbnail">
			<n:thumbnail>
				<xsl:call-template name="tbf:ED_no_tn">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:thumbnail>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:ED">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@encoding">
			<xsl:attribute name="encoding">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@mediaType">
			<xsl:attribute name="mediaType">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@compression">
			<xsl:attribute name="compression">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@integrityCheck">
			<xsl:attribute name="integrityCheck">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@integrityCheckAlgorithm">
			<xsl:attribute name="integrityCheckAlgorithm">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:reference">
			<n:reference>
				<xsl:call-template name="tbf:TEL">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:reference>
		</xsl:for-each>
		<xsl:for-each select="n:thumbnail">
			<n:thumbnail>
				<xsl:call-template name="tbf:ED_no_tn">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:thumbnail>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:SXCM_TS">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@value">
			<xsl:attribute name="value">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@operator">
			<xsl:attribute name="operator">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:CV">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@code">
			<xsl:attribute name="code">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystem">
			<xsl:attribute name="codeSystem">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemName">
			<xsl:attribute name="codeSystemName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemVersion">
			<xsl:attribute name="codeSystemVersion">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@displayName">
			<xsl:attribute name="displayName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:qualifier">
			<n:qualifier>
				<xsl:call-template name="tbf:CR">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:qualifier>
		</xsl:for-each>
		<xsl:for-each select="n:originalText">
			<n:originalText>
				<xsl:call-template name="tbf:ED">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:originalText>
		</xsl:for-each>
		<xsl:for-each select="n:translation">
			<n:translation>
				<xsl:call-template name="tbf:CD">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:translation>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:PQR">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@code">
			<xsl:attribute name="code">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystem">
			<xsl:attribute name="codeSystem">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemName">
			<xsl:attribute name="codeSystemName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemVersion">
			<xsl:attribute name="codeSystemVersion">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@displayName">
			<xsl:attribute name="displayName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@value">
			<xsl:attribute name="value">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:qualifier">
			<n:qualifier>
				<xsl:call-template name="tbf:CR">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:qualifier>
		</xsl:for-each>
		<xsl:for-each select="n:originalText">
			<n:originalText>
				<xsl:call-template name="tbf:ED">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:originalText>
		</xsl:for-each>
		<xsl:for-each select="n:translation">
			<n:translation>
				<xsl:call-template name="tbf:CD">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:translation>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:PQ">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@value">
			<xsl:attribute name="value">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@unit">
			<xsl:attribute name="unit">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:translation">
			<n:translation>
				<xsl:call-template name="tbf:PQR">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:translation>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:CR">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@code">
			<xsl:attribute name="code">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystem">
			<xsl:attribute name="codeSystem">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemName">
			<xsl:attribute name="codeSystemName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemVersion">
			<xsl:attribute name="codeSystemVersion">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@displayName">
			<xsl:attribute name="displayName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@inverted">
			<xsl:attribute name="inverted">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:qualifier">
			<n:qualifier>
				<xsl:call-template name="tbf:CR">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:qualifier>
		</xsl:for-each>
		<xsl:for-each select="n:originalText">
			<n:originalText>
				<xsl:call-template name="tbf:ED">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:originalText>
		</xsl:for-each>
		<xsl:for-each select="n:translation">
			<n:translation>
				<xsl:call-template name="tbf:CD">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:translation>
		</xsl:for-each>
		<xsl:for-each select="n:name">
			<n:name>
				<xsl:call-template name="tbf:CV">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:name>
		</xsl:for-each>
		<xsl:for-each select="n:value">
			<n:value>
				<xsl:call-template name="tbf:CD">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:value>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:CE">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@code">
			<xsl:attribute name="code">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystem">
			<xsl:attribute name="codeSystem">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemName">
			<xsl:attribute name="codeSystemName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemVersion">
			<xsl:attribute name="codeSystemVersion">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@displayName">
			<xsl:attribute name="displayName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:qualifier">
			<n:qualifier>
				<xsl:call-template name="tbf:CR">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:qualifier>
		</xsl:for-each>
		<xsl:for-each select="n:originalText">
			<n:originalText>
				<xsl:call-template name="tbf:ED">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:originalText>
		</xsl:for-each>
		<xsl:for-each select="n:translation">
			<n:translation>
				<xsl:call-template name="tbf:CD">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:translation>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:CD">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@code">
			<xsl:attribute name="code">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystem">
			<xsl:attribute name="codeSystem">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemName">
			<xsl:attribute name="codeSystemName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@codeSystemVersion">
			<xsl:attribute name="codeSystemVersion">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@displayName">
			<xsl:attribute name="displayName">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:qualifier">
			<n:qualifier>
				<xsl:call-template name="tbf:CR">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:qualifier>
		</xsl:for-each>
		<xsl:for-each select="n:originalText">
			<n:originalText>
				<xsl:call-template name="tbf:ED">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:originalText>
		</xsl:for-each>
		<xsl:for-each select="n:translation">
			<n:translation>
				<xsl:call-template name="tbf:CD">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:translation>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:TEL">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@value">
			<xsl:attribute name="value">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@use">
			<xsl:attribute name="use">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:validTime">
			<n:validTime>
				<xsl:call-template name="tbf:SXCM_TS">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:validTime>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:TS_inc">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@value">
			<xsl:attribute name="value">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@inclusive">
			<xsl:attribute name="inclusive">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:TS">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@value">
			<xsl:attribute name="value">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:IVL_TS">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@value">
			<xsl:attribute name="value">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@operator">
			<xsl:attribute name="operator">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:low">
			<n:low>
				<xsl:call-template name="tbf:TS_inc">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:low>
		</xsl:for-each>
		<xsl:for-each select="n:width">
			<n:width>
				<xsl:call-template name="tbf:PQ">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:width>
		</xsl:for-each>
		<xsl:for-each select="n:high">
			<n:high>
				<xsl:call-template name="tbf:TS_inc">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:high>
		</xsl:for-each>
		<xsl:for-each select="n:center">
			<n:center>
				<xsl:call-template name="tbf:TS">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:center>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="tbf:II">
		<xsl:param name="source"/>
		<xsl:for-each select="@nullFlavor">
			<xsl:attribute name="nullFlavor">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@root">
			<xsl:attribute name="root">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@extension">
			<xsl:attribute name="extension">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="@displayable">
			<xsl:attribute name="displayable">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
		<xsl:for-each select="n:validTime">
			<n:validTime>
				<xsl:call-template name="tbf:IVL_TS">
					<xsl:with-param name="source" select="."/>
				</xsl:call-template>
			</n:validTime>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="user:AnnotationCodeMap">
		<xsl:param name="input"/>
		<xsl:variable name="Vvar2_result">
			<xsl:call-template name="vmf:inputtoresult2">
				<xsl:with-param name="input" select="$input"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="Vvar5_result_equal" select="(number(string-length($Vvar2_result))) = (0)"/>
		<xsl:variable name="Vvar6_cond">
			<xsl:choose>
				<xsl:when test="(string($Vvar5_result_equal))='true'">
					<xsl:value-of select="$input"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$Vvar2_result"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:value-of select="$Vvar6_cond"/>
	</xsl:template>
	<xsl:template name="vmf:inputtoresult2">
		<xsl:param name="input"/>
		<xsl:choose>
			<xsl:when test="$input='P_DURATION'">
				<xsl:value-of select="'MDC_ECG_TIME_PD_P'"/>
			</xsl:when>
			<xsl:when test="$input='PR_DURATION'">
				<xsl:value-of select="'MDC_ECG_TIME_PD_PR'"/>
			</xsl:when>
			<xsl:when test="$input='QRS_DURATION'">
				<xsl:value-of select="'MDC_ECG_TIME_PD_QRS'"/>
			</xsl:when>
			<xsl:when test="$input='QT_DURATION'">
				<xsl:value-of select="'MDC_ECG_TIME_PD_QT'"/>
			</xsl:when>
			<xsl:when test="$input='QTC_DURATION'">
				<xsl:value-of select="'MDC_ECG_TIME_PD_QTc'"/>
			</xsl:when>
			<xsl:when test="$input='P_AXIS'">
				<xsl:value-of select="'MDC_ECG_ANGLE_P_FRONT'"/>
			</xsl:when>
			<xsl:when test="$input='QRS_AXIS'">
				<xsl:value-of select="'MDC_ECG_ANGLE_QRS_FRONT'"/>
			</xsl:when>
			<xsl:when test="$input='T_AXIS'">
				<xsl:value-of select="'MDC_ECG_ANGLE_T_FRONT'"/>
			</xsl:when>
			<xsl:when test="$input='BEAT'">
				<xsl:value-of select="'MDC_ECG_BEAT'"/>
			</xsl:when>
			<xsl:when test="$input='BEAT_FEATURE'">
				<xsl:value-of select="'MDC_ECG_WAVC'"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="vmf:inputtoresult">
		<xsl:param name="input"/>
		<xsl:choose>
			<xsl:when test="$input='REL_TIME'">
				<xsl:value-of select="'TIME_RELATIVE'"/>
			</xsl:when>
			<xsl:when test="$input='ABS_TIME'">
				<xsl:value-of select="'TIME_ABSOLUTE'"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:namespace-alias stylesheet-prefix="n" result-prefix="#default"/>
	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/n:AnnotatedECG">
		<n:AnnotatedECG>
			<xsl:attribute name="xsi:schemaLocation">
				<xsl:value-of select="'urn:hl7-org:v3 ../schema/PORT_MT020001.xsd'"/>
			</xsl:attribute>
			<xsl:variable name="Vvar1_firstSource" select="."/>
			<xsl:for-each select="@type">
				<xsl:variable name="Vvar472_type_string" select="string(.)"/>
				<xsl:attribute name="type">
					<xsl:value-of select="string($Vvar472_type_string)"/>
				</xsl:attribute>
			</xsl:for-each>
			<xsl:for-each select="@classCode">
				<xsl:variable name="Vvar476_classCode_string" select="string(.)"/>
				<xsl:attribute name="classCode">
					<xsl:value-of select="string($Vvar476_classCode_string)"/>
				</xsl:attribute>
			</xsl:for-each>
			<xsl:for-each select="n:id">
				<n:id>
					<xsl:choose>
						<xsl:when test="(@root and @extension)">
							<xsl:attribute name="root">
								<xsl:value-of select="@root"/>
							</xsl:attribute>
							<xsl:attribute name="extension">
								<xsl:value-of select="@extension"/>
							</xsl:attribute>
						</xsl:when>
						<xsl:when test="@root">
							<xsl:attribute name="root">
								<xsl:value-of select="@root"/>
							</xsl:attribute>
						</xsl:when>
						<xsl:when test="@extension">
							<xsl:attribute name="extension">
								<xsl:value-of select="@extension"/>
							</xsl:attribute>
						</xsl:when>
						<xsl:when test="@examID">
							<xsl:attribute name="extension">
								<xsl:value-of select="@examID"/>
							</xsl:attribute>
						</xsl:when>
						<xsl:otherwise>
							<xsl:attribute name="extension">
								<xsl:value-of select="'noId provided'"/>
							</xsl:attribute>
						</xsl:otherwise>
					</xsl:choose>
				</n:id>
			</xsl:for-each>
			<xsl:for-each select="n:code">
				<xsl:variable name="Vvar485_code" select="."/>
				<xsl:for-each select="$Vvar485_code">
					<n:code>
						<xsl:call-template name="tbf:CV">
							<xsl:with-param name="source" select="$Vvar485_code"/>
						</xsl:call-template>
					</n:code>
				</xsl:for-each>
			</xsl:for-each>
			<xsl:for-each select="n:effectiveTime">
				<xsl:variable name="Vvar487_effectiveTime" select="."/>
				<xsl:for-each select="$Vvar487_effectiveTime">
					<n:effectiveTime>
						<xsl:call-template name="tbf:IVL_TS">
							<xsl:with-param name="source" select="$Vvar487_effectiveTime"/>
						</xsl:call-template>
					</n:effectiveTime>
				</xsl:for-each>
			</xsl:for-each>
			<xsl:for-each select="n:componentOf">
				<n:componentOf>
					<xsl:for-each select="n:timepointEvent">
						<n:timepointEvent>
							<xsl:for-each select="@classCode">
								<xsl:variable name="Vvar494_classCode_string" select="string(.)"/>
								<xsl:attribute name="classCode">
									<xsl:value-of select="string($Vvar494_classCode_string)"/>
								</xsl:attribute>
							</xsl:for-each>
							<xsl:for-each select="n:code">
								<n:code>
									<xsl:for-each select="@code">
										<xsl:variable name="Vvar500_code_string" select="string(.)"/>
										<xsl:attribute name="code">
											<xsl:value-of select="string($Vvar500_code_string)"/>
										</xsl:attribute>
									</xsl:for-each>
									<xsl:for-each select="@codeSystem">
										<xsl:variable name="Vvar504_codeSystem_string" select="string(.)"/>
										<xsl:attribute name="codeSystem">
											<xsl:value-of select="$Vvar504_codeSystem_string"/>
										</xsl:attribute>
									</xsl:for-each>
								</n:code>
							</xsl:for-each>
							<xsl:for-each select="n:effectiveTime">
								<n:effectiveTime>
									<xsl:for-each select="n:low">
										<n:low>
											<xsl:for-each select="@value">
												<xsl:variable name="Vvar512_value_decimal" select="number(.)"/>
												<xsl:attribute name="value">
													<xsl:value-of select="string($Vvar512_value_decimal)"/>
												</xsl:attribute>
											</xsl:for-each>
											<xsl:for-each select="@inclusive">
												<xsl:variable name="Vvar518_inclusive_boolean" select="string(.)='true' or string(.)='1'"/>
												<xsl:attribute name="inclusive">
													<xsl:value-of select="string($Vvar518_inclusive_boolean)='true' or string($Vvar518_inclusive_boolean)='1'"/>
												</xsl:attribute>
											</xsl:for-each>
										</n:low>
									</xsl:for-each>
									<xsl:for-each select="n:high">
										<n:high>
											<xsl:for-each select="@value">
												<xsl:variable name="Vvar522_value_decimal" select="number(.)"/>
												<xsl:attribute name="value">
													<xsl:value-of select="string($Vvar522_value_decimal)"/>
												</xsl:attribute>
											</xsl:for-each>
											<xsl:for-each select="@inclusive">
												<xsl:variable name="Vvar528_inclusive_boolean" select="string(.)='true' or string(.)='1'"/>
												<xsl:attribute name="inclusive">
													<xsl:value-of select="string($Vvar528_inclusive_boolean)='true' or string($Vvar528_inclusive_boolean)='1'"/>
												</xsl:attribute>
											</xsl:for-each>
										</n:high>
									</xsl:for-each>
								</n:effectiveTime>
							</xsl:for-each>
							<xsl:for-each select="n:performer">
								<n:performer>
									<xsl:for-each select="@typeCode">
										<xsl:variable name="Vvar532_typeCode_string" select="string(.)"/>
										<xsl:attribute name="typeCode">
											<xsl:value-of select="string($Vvar532_typeCode_string)"/>
										</xsl:attribute>
									</xsl:for-each>
									<xsl:for-each select="n:studyEventPerformer">
										<n:studyEventPerformer>
											<xsl:for-each select="@classCode">
												<xsl:variable name="Vvar538_classCode_string" select="string(.)"/>
												<xsl:attribute name="classCode">
													<xsl:value-of select="string($Vvar538_classCode_string)"/>
												</xsl:attribute>
											</xsl:for-each>
											<xsl:for-each select="n:id">
												<n:id/>
											</xsl:for-each>
											<xsl:for-each select="n:assignedPerson">
												<n:assignedPerson>
													<xsl:for-each select="@classCode">
														<xsl:variable name="Vvar546_classCode_string" select="string(.)"/>
														<xsl:attribute name="classCode">
															<xsl:value-of select="string($Vvar546_classCode_string)"/>
														</xsl:attribute>
													</xsl:for-each>
													<xsl:for-each select="n:name">
														<xsl:variable name="Vvar552_name_string" select="string(.)"/>
														<n:name>
															<xsl:value-of select="$Vvar552_name_string"/>
														</n:name>
													</xsl:for-each>
												</n:assignedPerson>
											</xsl:for-each>
										</n:studyEventPerformer>
									</xsl:for-each>
								</n:performer>
							</xsl:for-each>
							<xsl:for-each select="n:componentOf">
								<n:componentOf>
									<xsl:for-each select="n:subjectAssignment">
										<n:subjectAssignment>
											<xsl:for-each select="@classCode">
												<xsl:variable name="Vvar558_classCode_string" select="string(.)"/>
												<xsl:attribute name="classCode">
													<xsl:value-of select="string($Vvar558_classCode_string)"/>
												</xsl:attribute>
											</xsl:for-each>
											<xsl:for-each select="n:subject">
												<n:subject>
													<xsl:for-each select="@typeCode">
														<xsl:variable name="Vvar564_typeCode_string" select="string(.)"/>
														<xsl:attribute name="typeCode">
															<xsl:value-of select="string($Vvar564_typeCode_string)"/>
														</xsl:attribute>
													</xsl:for-each>
													<xsl:for-each select="n:trialSubject">
														<n:trialSubject>
															<xsl:for-each select="@classCode">
																<xsl:variable name="Vvar570_classCode_string" select="string(.)"/>
																<xsl:attribute name="classCode">
																	<xsl:value-of select="string($Vvar570_classCode_string)"/>
																</xsl:attribute>
															</xsl:for-each>
															<xsl:for-each select="n:id">
																<n:id>
																	<xsl:for-each select="$Vvar1_firstSource/n:id">
																		<xsl:for-each select="@patientID">
																			<xsl:variable name="Vvar578_patientID_unsignedInt" select="number(.)"/>
																			<xsl:attribute name="extension">
																				<xsl:value-of select="string($Vvar578_patientID_unsignedInt)"/>
																			</xsl:attribute>
																		</xsl:for-each>
																	</xsl:for-each>
																</n:id>
															</xsl:for-each>
															<xsl:for-each select="n:subjectDemographicPerson">
																<n:subjectDemographicPerson>
																	<xsl:for-each select="@classCode">
																		<xsl:variable name="Vvar584_classCode_string" select="string(.)"/>
																		<xsl:attribute name="classCode">
																			<xsl:value-of select="string($Vvar584_classCode_string)"/>
																		</xsl:attribute>
																	</xsl:for-each>
																	<xsl:for-each select="n:name">
																		<n:name>
																			<xsl:for-each select="n:family">
																				<xsl:variable name="Vvar592_family_string" select="string(.)"/>
																				<n:family>
																					<xsl:value-of select="$Vvar592_family_string"/>
																				</n:family>
																			</xsl:for-each>
																			<xsl:for-each select="n:given">
																				<xsl:variable name="Vvar596_given_string" select="string(.)"/>
																				<n:given>
																					<xsl:value-of select="$Vvar596_given_string"/>
																				</n:given>
																			</xsl:for-each>
																		</n:name>
																	</xsl:for-each>
																	<xsl:for-each select="n:administrativeGenderCode">
																		<n:administrativeGenderCode>
																			<xsl:for-each select="@code">
																				<xsl:variable name="Vvar600_code_string" select="string(.)"/>
																				<xsl:attribute name="code">
																					<xsl:value-of select="string($Vvar600_code_string)"/>
																				</xsl:attribute>
																			</xsl:for-each>
																		</n:administrativeGenderCode>
																	</xsl:for-each>
																	<xsl:for-each select="n:birthTime">
																		<xsl:variable name="Vvar603_birthTime" select="."/>
																		<xsl:for-each select="$Vvar603_birthTime">
																			<n:birthTime>
																				<xsl:call-template name="tbf:TS">
																					<xsl:with-param name="source" select="$Vvar603_birthTime"/>
																				</xsl:call-template>
																			</n:birthTime>
																		</xsl:for-each>
																	</xsl:for-each>
																	<xsl:for-each select="n:raceCode">
																		<n:raceCode>
																			<xsl:for-each select="@code">
																				<xsl:variable name="Vvar609_code_string" select="string(.)"/>
																				<xsl:attribute name="code">
																					<xsl:value-of select="string($Vvar609_code_string)"/>
																				</xsl:attribute>
																			</xsl:for-each>
																		</n:raceCode>
																	</xsl:for-each>
																</n:subjectDemographicPerson>
															</xsl:for-each>
														</n:trialSubject>
													</xsl:for-each>
												</n:subject>
											</xsl:for-each>
										</n:subjectAssignment>
									</xsl:for-each>
								</n:componentOf>
							</xsl:for-each>
						</n:timepointEvent>
					</xsl:for-each>
				</n:componentOf>
			</xsl:for-each>
			<xsl:for-each select="n:component">
				<n:component>
					<xsl:for-each select="n:series">
						<n:series>
							<xsl:for-each select="@classCode">
								<xsl:variable name="Vvar617_classCode_string" select="string(.)"/>
								<xsl:attribute name="classCode">
									<xsl:value-of select="string($Vvar617_classCode_string)"/>
								</xsl:attribute>
							</xsl:for-each>
							<xsl:for-each select="n:id">
								<n:id>
									<xsl:for-each select="@fillerID">
										<xsl:variable name="Vvar625_fillerID_string" select="string(.)"/>
										<xsl:attribute name="extension">
											<xsl:value-of select="$Vvar625_fillerID_string"/>
										</xsl:attribute>
									</xsl:for-each>
								</n:id>
							</xsl:for-each>
							<xsl:for-each select="n:code">
								<xsl:variable name="Vvar626_code" select="."/>
								<xsl:for-each select="$Vvar626_code">
									<n:code>
										<xsl:call-template name="tbf:CE">
											<xsl:with-param name="source" select="$Vvar626_code"/>
										</xsl:call-template>
									</n:code>
								</xsl:for-each>
							</xsl:for-each>
							<xsl:for-each select="n:effectiveTime">
								<xsl:variable name="Vvar628_effectiveTime" select="."/>
								<xsl:for-each select="$Vvar628_effectiveTime">
									<n:effectiveTime>
										<xsl:call-template name="tbf:IVL_TS">
											<xsl:with-param name="source" select="$Vvar628_effectiveTime"/>
										</xsl:call-template>
									</n:effectiveTime>
								</xsl:for-each>
							</xsl:for-each>
							<xsl:for-each select="n:author">
								<n:author>
									<xsl:for-each select="@typeCode">
										<xsl:variable name="Vvar633_typeCode_string" select="string(.)"/>
										<xsl:attribute name="typeCode">
											<xsl:value-of select="string($Vvar633_typeCode_string)"/>
										</xsl:attribute>
									</xsl:for-each>
									<n:seriesAuthor>
										<xsl:for-each select="n:manufacturedProduct">
											<xsl:for-each select="@classCode">
												<xsl:variable name="Vvar639_classCode_string" select="string(.)"/>
												<xsl:attribute name="classCode">
													<xsl:value-of select="string($Vvar639_classCode_string)"/>
												</xsl:attribute>
											</xsl:for-each>
										</xsl:for-each>
										<xsl:for-each select="n:manufacturedProduct">
											<xsl:for-each select="n:manufacturedDevice">
												<n:manufacturedSeriesDevice>
													<xsl:for-each select="@classCode">
														<xsl:variable name="Vvar647_classCode_string" select="string(.)"/>
														<xsl:attribute name="classCode">
															<xsl:value-of select="string($Vvar647_classCode_string)"/>
														</xsl:attribute>
													</xsl:for-each>
													<xsl:for-each select="n:manufacturerModelName">
														<xsl:variable name="Vvar653_manufacturerModelName_string" select="string(.)"/>
														<n:manufacturerModelName>
															<xsl:value-of select="$Vvar653_manufacturerModelName_string"/>
														</n:manufacturerModelName>
													</xsl:for-each>
													<xsl:for-each select="n:softwareName">
														<xsl:variable name="Vvar657_softwareName_string" select="string(.)"/>
														<n:softwareName>
															<xsl:value-of select="$Vvar657_softwareName_string"/>
														</n:softwareName>
													</xsl:for-each>
												</n:manufacturedSeriesDevice>
											</xsl:for-each>
										</xsl:for-each>
										<xsl:for-each select="n:manufacturedProduct">
											<xsl:for-each select="n:manufacturerOrganization">
												<n:manufacturerOrganization>
													<xsl:for-each select="@classCode">
														<xsl:variable name="Vvar663_classCode_string" select="string(.)"/>
														<xsl:attribute name="classCode">
															<xsl:value-of select="string($Vvar663_classCode_string)"/>
														</xsl:attribute>
													</xsl:for-each>
													<xsl:for-each select="n:name">
														<xsl:variable name="Vvar669_name_string" select="string(.)"/>
														<n:name>
															<xsl:value-of select="$Vvar669_name_string"/>
														</n:name>
													</xsl:for-each>
												</n:manufacturerOrganization>
											</xsl:for-each>
										</xsl:for-each>
									</n:seriesAuthor>
								</n:author>
							</xsl:for-each>
							<xsl:for-each select="n:component">
								<n:component>
									<xsl:for-each select="n:sequenceSet">
										<n:sequenceSet>
											<xsl:for-each select="@classCode">
												<xsl:variable name="Vvar675_classCode_string" select="string(.)"/>
												<xsl:attribute name="classCode">
													<xsl:value-of select="string($Vvar675_classCode_string)"/>
												</xsl:attribute>
											</xsl:for-each>
											<xsl:for-each select="n:component">
												<n:component>
													<xsl:for-each select="n:sequence">
														<n:sequence>
															<xsl:for-each select="@classCode">
																<xsl:variable name="Vvar683_classCode_string" select="string(.)"/>
																<xsl:attribute name="classCode">
																	<xsl:value-of select="string($Vvar683_classCode_string)"/>
																</xsl:attribute>
															</xsl:for-each>
															<xsl:for-each select="n:code">
																<n:code>
																	<xsl:for-each select="@code">
																		<xsl:variable name="Vvar689_code_string" select="string(.)"/>
																		<xsl:attribute name="code">
																			<xsl:value-of select="string(translate($Vvar689_code_string, 'NOM_', 'MDC_'))"/>
																		</xsl:attribute>
																	</xsl:for-each>
																	<xsl:for-each select="@codeSystem">
																		<xsl:variable name="Vvar696_codeSystem_string" select="string(.)"/>
																		<xsl:attribute name="codeSystem">
																			<xsl:value-of select="$Vvar696_codeSystem_string"/>
																		</xsl:attribute>
																	</xsl:for-each>
																</n:code>
															</xsl:for-each>
															<xsl:for-each select="n:value">
																<n:value>
																	<xsl:copy-of select="@*"/>
																	<xsl:copy-of select="node()"/>
																</n:value>
															</xsl:for-each>
														</n:sequence>
													</xsl:for-each>
												</n:component>
											</xsl:for-each>
										</n:sequenceSet>
									</xsl:for-each>
								</n:component>
							</xsl:for-each>
							<xsl:for-each select="n:subjectOf">
								<n:subjectOf>
									<n:annotationSet>
										<n:component>
											<xsl:for-each select="n:annotation">
												<n:annotation>
													<xsl:for-each select="@classCode">
														<xsl:variable name="Vvar706_classCode_string" select="string(.)"/>
														<xsl:attribute name="classCode">
															<xsl:value-of select="string($Vvar706_classCode_string)"/>
														</xsl:attribute>
													</xsl:for-each>
													<xsl:for-each select="n:code">
														<n:code>
															<xsl:for-each select="@code">
																<xsl:variable name="Vvar712_code_string" select="string(.)"/>
																<xsl:variable name="Vvar714_result_AnnotationCodeMap">
																	<xsl:call-template name="user:AnnotationCodeMap">
																		<xsl:with-param name="input" select="$Vvar712_code_string"/>
																	</xsl:call-template>
																</xsl:variable>
																<xsl:attribute name="code">
																	<xsl:value-of select="string($Vvar714_result_AnnotationCodeMap)"/>
																</xsl:attribute>
															</xsl:for-each>
															<xsl:for-each select="@codeSystem">
																<xsl:variable name="Vvar717_codeSystem_string" select="string(.)"/>
																<xsl:attribute name="codeSystem">
																	<xsl:value-of select="$Vvar717_codeSystem_string"/>
																</xsl:attribute>
															</xsl:for-each>
														</n:code>
													</xsl:for-each>
													<xsl:for-each select="n:value">
														<n:value>
															<xsl:copy-of select="@*"/>
															<xsl:if test="@code">
																<xsl:attribute name="code">
																	<xsl:choose>
																		<xsl:when test="@code='PWAVE'">
																			<xsl:value-of select="'MDC_ECG_WAVC_PWAVE'"/>
																		</xsl:when>
																		<xsl:when test="@code='QRS'">
																			<xsl:value-of select="'MDC_ECG_WAVC_QRSWAVE'"/>
																		</xsl:when>
																		<xsl:when test="@code='TWAVE'">
																			<xsl:value-of select="'MDC_ECG_WAVC_TWAVE'"/>
																		</xsl:when>
																		<xsl:otherwise>
																			<xsl:value-of select="@code"/>
																		</xsl:otherwise>
																	</xsl:choose>
																</xsl:attribute>
															</xsl:if>
															<xsl:copy-of select="node()"/>
														</n:value>
													</xsl:for-each>
													<xsl:for-each select="n:support">
														<n:support>
															<xsl:for-each select="n:supportingROI">
																<n:supportingROI>
																	<xsl:for-each select="@classCode">
																		<xsl:variable name="Vvar727_classCode_string" select="string(.)"/>
																		<xsl:attribute name="classCode">
																			<xsl:value-of select="string($Vvar727_classCode_string)"/>
																		</xsl:attribute>
																	</xsl:for-each>
																	<xsl:for-each select="n:code">
																		<xsl:variable name="Vvar730_code" select="."/>
																		<xsl:for-each select="$Vvar730_code">
																			<n:code>
																				<xsl:call-template name="tbf:CD">
																					<xsl:with-param name="source" select="$Vvar730_code"/>
																				</xsl:call-template>
																			</n:code>
																		</xsl:for-each>
																	</xsl:for-each>
																	<xsl:for-each select="n:component">
																		<n:component>
																			<xsl:for-each select="n:boundary">
																				<n:boundary>
																					<xsl:for-each select="@classCode">
																						<xsl:variable name="Vvar737_classCode_string" select="string(.)"/>
																						<xsl:attribute name="classCode">
																							<xsl:value-of select="string($Vvar737_classCode_string)"/>
																						</xsl:attribute>
																					</xsl:for-each>
																					<xsl:for-each select="n:code">
																						<n:code>
																							<xsl:for-each select="@code">
																								<xsl:variable name="Vvar743_code_string" select="string(.)"/>
																								<xsl:variable name="Vvar745_result">
																									<xsl:call-template name="vmf:inputtoresult">
																										<xsl:with-param name="input" select="$Vvar743_code_string"/>
																									</xsl:call-template>
																								</xsl:variable>
																								<xsl:variable name="Vvar748_result_equal" select="(number(string-length($Vvar745_result))) = (0)"/>
																								<xsl:variable name="Vvar749_cond">
																									<xsl:choose>
																										<xsl:when test="(string($Vvar748_result_equal))='true'">
																											<xsl:value-of select="$Vvar743_code_string"/>
																										</xsl:when>
																										<xsl:otherwise>
																											<xsl:value-of select="$Vvar745_result"/>
																										</xsl:otherwise>
																									</xsl:choose>
																								</xsl:variable>
																								<xsl:attribute name="code">
																									<xsl:value-of select="string($Vvar749_cond)"/>
																								</xsl:attribute>
																							</xsl:for-each>
																						</n:code>
																					</xsl:for-each>
																					<xsl:for-each select="n:value">
																						<n:value>
																							<xsl:copy-of select="@*"/>
																							<xsl:copy-of select="node()"/>
																						</n:value>
																					</xsl:for-each>
																				</n:boundary>
																			</xsl:for-each>
																		</n:component>
																	</xsl:for-each>
																</n:supportingROI>
															</xsl:for-each>
														</n:support>
													</xsl:for-each>
													<xsl:for-each select="n:component">
														<n:component>
															<xsl:for-each select="n:Annotation">
																<n:annotation>
																	<xsl:for-each select="@classCode">
																		<xsl:variable name="Vvar758_classCode_string" select="string(.)"/>
																		<xsl:attribute name="classCode">
																			<xsl:value-of select="string($Vvar758_classCode_string)"/>
																		</xsl:attribute>
																	</xsl:for-each>
																	<xsl:for-each select="n:code">
																		<n:code>
																			<xsl:for-each select="@code">
																				<xsl:variable name="Vvar764_code_string" select="string(.)"/>
																				<xsl:variable name="Vvar766_result_AnnotationCodeMap">
																					<xsl:call-template name="user:AnnotationCodeMap">
																						<xsl:with-param name="input" select="$Vvar764_code_string"/>
																					</xsl:call-template>
																				</xsl:variable>
																				<xsl:attribute name="code">
																					<xsl:value-of select="string($Vvar766_result_AnnotationCodeMap)"/>
																				</xsl:attribute>
																			</xsl:for-each>
																			<xsl:for-each select="@codeSystem">
																				<xsl:variable name="Vvar769_codeSystem_string" select="string(.)"/>
																				<xsl:attribute name="codeSystem">
																					<xsl:value-of select="$Vvar769_codeSystem_string"/>
																				</xsl:attribute>
																			</xsl:for-each>
																		</n:code>
																	</xsl:for-each>
																	<xsl:for-each select="n:value">
																		<n:value>
																			<xsl:copy-of select="@*"/>
																			<xsl:if test="@code">
																				<xsl:attribute name="code">
																					<xsl:choose>
																						<xsl:when test="@code='PWAVE'">
																							<xsl:value-of select="'MDC_ECG_WAVC_PWAVE'"/>
																						</xsl:when>
																						<xsl:when test="@code='QRS'">
																							<xsl:value-of select="'MDC_ECG_WAVC_QRSWAVE'"/>
																						</xsl:when>
																						<xsl:when test="@code='TWAVE'">
																							<xsl:value-of select="'MDC_ECG_WAVC_TWAVE'"/>
																						</xsl:when>
																						<xsl:otherwise>
																							<xsl:value-of select="@code"/>
																						</xsl:otherwise>
																					</xsl:choose>
																				</xsl:attribute>
																			</xsl:if>
																			<xsl:copy-of select="node()"/>
																		</n:value>
																	</xsl:for-each>
																	<xsl:for-each select="n:support">
																		<n:support>
																			<xsl:for-each select="n:supportingROI">
																				<n:supportingROI>
																					<xsl:for-each select="@classCode">
																						<xsl:variable name="Vvar779_classCode_string" select="string(.)"/>
																						<xsl:attribute name="classCode">
																							<xsl:value-of select="string($Vvar779_classCode_string)"/>
																						</xsl:attribute>
																					</xsl:for-each>
																					<xsl:for-each select="n:code">
																						<xsl:variable name="Vvar782_code" select="."/>
																						<xsl:for-each select="$Vvar782_code">
																							<n:code>
																								<xsl:call-template name="tbf:CD">
																									<xsl:with-param name="source" select="$Vvar782_code"/>
																								</xsl:call-template>
																							</n:code>
																						</xsl:for-each>
																					</xsl:for-each>
																					<xsl:for-each select="n:component">
																						<n:component>
																							<xsl:for-each select="n:boundary">
																								<n:boundary>
																									<xsl:for-each select="@classCode">
																										<xsl:variable name="Vvar789_classCode_string" select="string(.)"/>
																										<xsl:attribute name="classCode">
																											<xsl:value-of select="string($Vvar789_classCode_string)"/>
																										</xsl:attribute>
																									</xsl:for-each>
																									<xsl:for-each select="n:code">
																										<n:code>
																											<xsl:for-each select="@code">
																												<xsl:variable name="Vvar795_code_string" select="string(.)"/>
																												<xsl:variable name="Vvar797_result">
																													<xsl:call-template name="vmf:inputtoresult">
																														<xsl:with-param name="input" select="$Vvar795_code_string"/>
																													</xsl:call-template>
																												</xsl:variable>
																												<xsl:variable name="Vvar800_result_equal" select="(number(string-length($Vvar797_result))) = (0)"/>
																												<xsl:variable name="Vvar801_cond">
																													<xsl:choose>
																														<xsl:when test="(string($Vvar800_result_equal))='true'">
																															<xsl:value-of select="$Vvar795_code_string"/>
																														</xsl:when>
																														<xsl:otherwise>
																															<xsl:value-of select="$Vvar797_result"/>
																														</xsl:otherwise>
																													</xsl:choose>
																												</xsl:variable>
																												<xsl:attribute name="code">
																													<xsl:value-of select="string($Vvar801_cond)"/>
																												</xsl:attribute>
																											</xsl:for-each>
																										</n:code>
																									</xsl:for-each>
																									<xsl:for-each select="n:value">
																										<n:value>
																											<xsl:copy-of select="@*"/>
																											<xsl:copy-of select="node()"/>
																										</n:value>
																									</xsl:for-each>
																								</n:boundary>
																							</xsl:for-each>
																						</n:component>
																					</xsl:for-each>
																				</n:supportingROI>
																			</xsl:for-each>
																		</n:support>
																	</xsl:for-each>
																</n:annotation>
															</xsl:for-each>
														</n:component>
													</xsl:for-each>
												</n:annotation>
											</xsl:for-each>
										</n:component>
									</n:annotationSet>
								</n:subjectOf>
							</xsl:for-each>
							<xsl:for-each select="n:derivation">
								<n:derivation>
									<xsl:for-each select="n:Series">
										<n:derivedSeries>
											<xsl:for-each select="@classCode">
												<xsl:variable name="Vvar810_classCode_string" select="string(.)"/>
												<xsl:attribute name="classCode">
													<xsl:value-of select="string($Vvar810_classCode_string)"/>
												</xsl:attribute>
											</xsl:for-each>
											<xsl:for-each select="n:id">
												<xsl:variable name="Vvar813_id" select="."/>
												<xsl:for-each select="$Vvar813_id">
													<n:id>
														<xsl:call-template name="tbf:II">
															<xsl:with-param name="source" select="$Vvar813_id"/>
														</xsl:call-template>
													</n:id>
												</xsl:for-each>
											</xsl:for-each>
											<xsl:for-each select="n:code">
												<xsl:variable name="Vvar815_code" select="."/>
												<xsl:for-each select="$Vvar815_code">
													<n:code>
														<xsl:call-template name="tbf:CE">
															<xsl:with-param name="source" select="$Vvar815_code"/>
														</xsl:call-template>
													</n:code>
												</xsl:for-each>
											</xsl:for-each>
											<xsl:for-each select="n:effectiveTime">
												<xsl:variable name="Vvar817_effectiveTime" select="."/>
												<xsl:for-each select="$Vvar817_effectiveTime">
													<n:effectiveTime>
														<xsl:call-template name="tbf:IVL_TS">
															<xsl:with-param name="source" select="$Vvar817_effectiveTime"/>
														</xsl:call-template>
													</n:effectiveTime>
												</xsl:for-each>
											</xsl:for-each>
											<xsl:for-each select="n:author">
												<n:author>
													<xsl:for-each select="@typeCode">
														<xsl:variable name="Vvar822_typeCode_string" select="string(.)"/>
														<xsl:attribute name="typeCode">
															<xsl:value-of select="string($Vvar822_typeCode_string)"/>
														</xsl:attribute>
													</xsl:for-each>
													<n:seriesAuthor>
														<xsl:for-each select="n:manufacturedProduct">
															<xsl:for-each select="n:manufacturedDevice">
																<n:manufacturedSeriesDevice>
																	<xsl:for-each select="@classCode">
																		<xsl:variable name="Vvar830_classCode_string" select="string(.)"/>
																		<xsl:attribute name="classCode">
																			<xsl:value-of select="string($Vvar830_classCode_string)"/>
																		</xsl:attribute>
																	</xsl:for-each>
																	<xsl:for-each select="n:manufacturerModelName">
																		<xsl:variable name="Vvar836_manufacturerModelName_string" select="string(.)"/>
																		<n:manufacturerModelName>
																			<xsl:value-of select="$Vvar836_manufacturerModelName_string"/>
																		</n:manufacturerModelName>
																	</xsl:for-each>
																	<xsl:for-each select="n:softwareName">
																		<xsl:variable name="Vvar840_softwareName_string" select="string(.)"/>
																		<n:softwareName>
																			<xsl:value-of select="$Vvar840_softwareName_string"/>
																		</n:softwareName>
																	</xsl:for-each>
																</n:manufacturedSeriesDevice>
															</xsl:for-each>
														</xsl:for-each>
														<xsl:for-each select="n:manufacturedProduct">
															<xsl:for-each select="n:manufacturerOrganization">
																<n:manufacturerOrganization>
																	<xsl:for-each select="@classCode">
																		<xsl:variable name="Vvar846_classCode_string" select="string(.)"/>
																		<xsl:attribute name="classCode">
																			<xsl:value-of select="string($Vvar846_classCode_string)"/>
																		</xsl:attribute>
																	</xsl:for-each>
																	<xsl:for-each select="n:name">
																		<xsl:variable name="Vvar852_name_string" select="string(.)"/>
																		<n:name>
																			<xsl:value-of select="$Vvar852_name_string"/>
																		</n:name>
																	</xsl:for-each>
																</n:manufacturerOrganization>
															</xsl:for-each>
														</xsl:for-each>
													</n:seriesAuthor>
												</n:author>
											</xsl:for-each>
											<xsl:for-each select="n:component">
												<n:component>
													<xsl:for-each select="n:sequenceSet">
														<n:sequenceSet>
															<xsl:for-each select="@classCode">
																<xsl:variable name="Vvar858_classCode_string" select="string(.)"/>
																<xsl:attribute name="classCode">
																	<xsl:value-of select="string($Vvar858_classCode_string)"/>
																</xsl:attribute>
															</xsl:for-each>
															<xsl:for-each select="n:component">
																<n:component>
																	<xsl:for-each select="n:sequence">
																		<n:sequence>
																			<xsl:for-each select="n:code">
																				<n:code>
																					<xsl:for-each select="@code">
																						<xsl:variable name="Vvar868_code_string" select="string(.)"/>
																						<xsl:attribute name="code">
																							<xsl:value-of select="string(translate($Vvar868_code_string, 'NOM_', 'MDC_'))"/>
																						</xsl:attribute>
																					</xsl:for-each>
																					<xsl:for-each select="@codeSystem">
																						<xsl:variable name="Vvar875_codeSystem_string" select="string(.)"/>
																						<xsl:attribute name="codeSystem">
																							<xsl:value-of select="$Vvar875_codeSystem_string"/>
																						</xsl:attribute>
																					</xsl:for-each>
																				</n:code>
																			</xsl:for-each>
																			<xsl:for-each select="n:value">
																				<n:value>
																					<xsl:copy-of select="@*"/>
																					<xsl:copy-of select="node()"/>
																				</n:value>
																			</xsl:for-each>
																		</n:sequence>
																	</xsl:for-each>
																</n:component>
															</xsl:for-each>
														</n:sequenceSet>
													</xsl:for-each>
												</n:component>
											</xsl:for-each>
											<n:subjectOf>
												<n:annotationSet>
													<xsl:for-each select="n:subjectOf">
														<n:component>
															<xsl:for-each select="n:annotation">
																<n:annotation>
																	<xsl:for-each select="@classCode">
																		<xsl:variable name="Vvar885_classCode_string" select="string(.)"/>
																		<xsl:attribute name="classCode">
																			<xsl:value-of select="string($Vvar885_classCode_string)"/>
																		</xsl:attribute>
																	</xsl:for-each>
																	<xsl:for-each select="n:code">
																		<n:code>
																			<xsl:for-each select="@code">
																				<xsl:variable name="Vvar891_code_string" select="string(.)"/>
																				<xsl:variable name="Vvar893_result_AnnotationCodeMap">
																					<xsl:call-template name="user:AnnotationCodeMap">
																						<xsl:with-param name="input" select="$Vvar891_code_string"/>
																					</xsl:call-template>
																				</xsl:variable>
																				<xsl:attribute name="code">
																					<xsl:value-of select="string($Vvar893_result_AnnotationCodeMap)"/>
																				</xsl:attribute>
																			</xsl:for-each>
																			<xsl:for-each select="@codeSystem">
																				<xsl:variable name="Vvar896_codeSystem_string" select="string(.)"/>
																				<xsl:attribute name="codeSystem">
																					<xsl:value-of select="$Vvar896_codeSystem_string"/>
																				</xsl:attribute>
																			</xsl:for-each>
																		</n:code>
																	</xsl:for-each>
																	<xsl:for-each select="n:value">
																		<n:value>
																			<xsl:copy-of select="@*"/>
																			<xsl:if test="@code">
																				<xsl:attribute name="code">
																					<xsl:choose>
																						<xsl:when test="@code='PWAVE'">
																							<xsl:value-of select="'MDC_ECG_WAVC_PWAVE'"/>
																						</xsl:when>
																						<xsl:when test="@code='QRS'">
																							<xsl:value-of select="'MDC_ECG_WAVC_QRSWAVE'"/>
																						</xsl:when>
																						<xsl:when test="@code='TWAVE'">
																							<xsl:value-of select="'MDC_ECG_WAVC_TWAVE'"/>
																						</xsl:when>
																						<xsl:otherwise>
																							<xsl:value-of select="@code"/>
																						</xsl:otherwise>
																					</xsl:choose>
																				</xsl:attribute>
																			</xsl:if>
																			<xsl:copy-of select="node()"/>
																		</n:value>
																	</xsl:for-each>
																	<xsl:for-each select="n:support">
																		<n:support>
																			<xsl:for-each select="n:supportingROI">
																				<n:supportingROI>
																					<xsl:for-each select="@classCode">
																						<xsl:variable name="Vvar906_classCode_string" select="string(.)"/>
																						<xsl:attribute name="classCode">
																							<xsl:value-of select="string($Vvar906_classCode_string)"/>
																						</xsl:attribute>
																					</xsl:for-each>
																					<xsl:for-each select="n:code">
																						<n:code>
																							<xsl:for-each select="@code">
																								<xsl:variable name="Vvar912_code_string" select="string(.)"/>
																								<xsl:attribute name="code">
																									<xsl:value-of select="string($Vvar912_code_string)"/>
																								</xsl:attribute>
																							</xsl:for-each>
																						</n:code>
																					</xsl:for-each>
																					<xsl:for-each select="n:component">
																						<n:component>
																							<xsl:for-each select="n:boundary">
																								<n:boundary>
																									<xsl:for-each select="@classCode">
																										<xsl:variable name="Vvar920_classCode_string" select="string(.)"/>
																										<xsl:attribute name="classCode">
																											<xsl:value-of select="string($Vvar920_classCode_string)"/>
																										</xsl:attribute>
																									</xsl:for-each>
																									<xsl:for-each select="n:code">
																										<n:code>
																											<xsl:for-each select="@code">
																												<xsl:variable name="Vvar926_code_string" select="string(.)"/>
																												<xsl:variable name="Vvar928_result">
																													<xsl:call-template name="vmf:inputtoresult">
																														<xsl:with-param name="input" select="$Vvar926_code_string"/>
																													</xsl:call-template>
																												</xsl:variable>
																												<xsl:variable name="Vvar931_result_equal" select="(number(string-length($Vvar928_result))) = (0)"/>
																												<xsl:variable name="Vvar932_cond">
																													<xsl:choose>
																														<xsl:when test="(string($Vvar931_result_equal))='true'">
																															<xsl:value-of select="$Vvar926_code_string"/>
																														</xsl:when>
																														<xsl:otherwise>
																															<xsl:value-of select="$Vvar928_result"/>
																														</xsl:otherwise>
																													</xsl:choose>
																												</xsl:variable>
																												<xsl:attribute name="code">
																													<xsl:value-of select="string($Vvar932_cond)"/>
																												</xsl:attribute>
																											</xsl:for-each>
																										</n:code>
																									</xsl:for-each>
																									<xsl:for-each select="n:value">
																										<n:value>
																											<xsl:copy-of select="@*"/>
																											<xsl:copy-of select="node()"/>
																										</n:value>
																									</xsl:for-each>
																								</n:boundary>
																							</xsl:for-each>
																						</n:component>
																					</xsl:for-each>
																				</n:supportingROI>
																			</xsl:for-each>
																		</n:support>
																	</xsl:for-each>
																</n:annotation>
															</xsl:for-each>
														</n:component>
													</xsl:for-each>
												</n:annotationSet>
											</n:subjectOf>
										</n:derivedSeries>
									</xsl:for-each>
								</n:derivation>
							</xsl:for-each>
						</n:series>
					</xsl:for-each>
				</n:component>
			</xsl:for-each>
		</n:AnnotatedECG>
	</xsl:template>
</xsl:stylesheet>
